<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 图片移入移出改变透明度 -->
    <div class="box">
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
        <div class="box1">
            <img src="./src=http___ci.xiaohongshu.com_86233825-3e2b-7279-d656-12fff2957c3e_imageView2_2_w_1080_format_jpg&refer=http___ci.xiaohongshu.webp"
                alt="">
            <div class="item"></div>
        </div>
    </div>
</body>
<script>
    let item = document.querySelectorAll(".item")
    console.log(item.length) 
    for (let i = 0; i < item.length; i++) {
        item[i].onmouseover = function () {
            for (let j = 0; j < item.length; j++) {
                item[j].style.background = "rgba(255, 255, 255, 0.7)"
            } 
            this.style.background = "rgba(255, 255, 255, 0)"
        } 
    }

    for(let a=0;a<item.length;a++){
         item[a].onmouseout=function(){
             for(let b=0;b<item.length;b++){
                item[b].style.background = "rgba(255, 255, 255, 0.7)"
             }
         }  
    }

</script>

</html>
<style>
    .box {
        width: 636px;
        height: 319px;
        border: 1px solid red;
        margin: 0 auto;
        display: flex;
        flex-wrap: wrap;
    }

    .box1 {
        width: 145px;
        height: 145px;
        border: 2px solid black;
        margin: 5px;
        position: relative;
    }

    img {
        width: 100%;
        height: 100%;
    }

    .item {
        width: 100%;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.7);
        position: absolute;
        top: 0px;
        left: 0px;

    }
</style>